import fetch from '@/utils/fetch'

export function loginByUsername(username, password) {
  const data = {
    'email': username,
    'password': password
  }
  return fetch({
    url: 'api/student/login',
    method: 'post',
    data
  })
}

export function logout() {
  return fetch({
    url: '/login/logout',
    method: 'post'
  })
}

export function getUserInfo(token) {
  return fetch({
    url: 'api/student/details',
    method: 'get'
  })
}

export function register(username, password, c_password) {
  const data = {
    'email': username,
    'password': password,
    'c_password': c_password
  }
  return fetch({
    url: 'api/student/register',
    method: 'post',
    data
  })
}

